﻿@{
    Layout = "~/_SiteLayout.cshtml";

    Business.Platform.WorkFlowTask bworkFlowTask = new Business.Platform.WorkFlowTask();
    Business.Platform.WorkFlow bworkFlow = new Business.Platform.WorkFlow();

    string flowid = Request.QueryString["flowid1"] ?? Request.QueryString["flowid"];
    string groupid = Request.QueryString["groupid"];
    string displayModel = Request.QueryString["displaymodel"];
    
    var wfInstall = bworkFlow.GetWorkFlowRunModel(flowid);
    var tasks = bworkFlowTask.GetTaskList(flowid.ToGuid(), groupid.ToGuid()).OrderBy(p => p.Sort);
    string query = string.Format("&flowid1={0}&groupid={1}&appid={2}&tabid={3}&title={4}&flowid={5}&sender={6}&date1={7}&date2={8}&iframeid={9}&openerid={10}",
        flowid,groupid,
        Request.QueryString["appid"],
        Request.QueryString["tabid"],
        Request.QueryString["title"].UrlEncode(),
        Request.QueryString["flowid"],
        Request.QueryString["sender"],
        Request.QueryString["date1"],
        Request.QueryString["date2"],
        Request.QueryString["iframeid"],
        Request.QueryString["openerid"]
        );
}
<div class="toolbar" style="margin-top:0; border-top:0;">
    <a href="javascript:void(0);" onclick="window.location='Detail?displaymodel=1'+'@query';return false;"><span style="background-image:url(/Images/ico/shape_aling_left.png);">图形方式</span></a>
    <input type="submit" style="display:none;" value="d" id="DeleteBut" name="DeleteBut" />
    <a href="javascript:void(0);" onclick="window.location='Detail?displaymodel=0'+'@query';return false;"><span style="background-image:url(/Images/ico/table.gif);">列表方式</span></a>
    <span class="toolbarsplit">&nbsp;</span>
    <a href="javascript:void(0);" onclick="new RoadUI.Window().close();return false;"><span style="background-image:url(/Images/ico/application_osx_remove.png);">关闭窗口</span></a>
</div>
@if ("1" != displayModel)
{
<table cellpadding="0" cellspacing="1" border="0" class="listtable" style="width:99%; margin-top:5px;">
    <thead>
        <tr>
            <th>步骤名称</th>
            <th>发送人</th>
            <th>发送时间</th>
            <th>处理人</th>
            <th>完成时间</th>
            <th>状态</th>
            <th>意见</th>
            <th>备注</th>
        </tr>
    </thead>
    <tbody>
    @foreach (var task in tasks)
    {
        <tr>
            <td>@bworkFlow.GetStepName(task.StepID, wfInstall)</td>
            <td>@task.SenderName</td>
            <td>@task.SenderTime</td>
            <td>@task.ReceiveName</td>
            <td>@task.CompletedTime1</td>
            <td>@bworkFlowTask.GetStatusTitle(task.Status)</td>
            <td>@task.Comment</td>
            <td>@task.Note</td>
        </tr>
    }
    </tbody>
</table>
}
else
{
    int taskCount = tasks.Count();
    int i = 0;
    System.Text.StringBuilder tasksjson = new System.Text.StringBuilder("[",tasks.Count()*60);
    foreach (var task in tasks)
    {
        tasksjson.Append("{");
        tasksjson.AppendFormat("\"stepid\":\"{0}\",\"prevstepid\":\"{1}\",\"status\":\"{2}\"",
            task.StepID, task.PrevStepID, task.Status);
        tasksjson.Append("}");
        if (i++ < taskCount - 1)
        {
            tasksjson.Append(",");
        }
    }
    tasksjson.Append("]");
    <div style="padding:8px 5px 0 10px;">
        <span style="display:inline-block; height:12px; width:12px; background:#7e7e7f; margin-left:6px; vertical-align:middle;"></span>
        <label style="vertical-align:middle;">未经过步骤</label>
        <span style="display:inline-block; height:12px; width:12px; background:green; margin-left:6px; vertical-align:middle;"></span>
        <label style="vertical-align:middle;">已完成步骤</label>
        <span style="display:inline-block; height:12px; width:12px; background:#ff9001; margin-left:6px; vertical-align:middle;"></span>
        <label style="vertical-align:middle;">待处理步骤</label>
    </div>
    <div id="flowdiv" style="margin:0; padding:0; overflow:auto;"></div>
    <script type="text/javascript">
        var taskJSON=@Html.Raw(tasksjson.ToString());
    </script>
    <script src="../Designer/draw-min.js" type="text/javascript"></script>
    <script src="../Designer/workflow-show.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function ()
        {
            openFlow1('@flowid');
        });
    </script>
}